LATEX and document-style files

Before the I discuss some of the code in the babel system I would like to discuss the document-style mechanism used by LATEX. Every LATEX document should start with a line like:

\documentstyle[opt1,opt2,...]{docstyle}
This line of code instructs LATEX to first load the file docstyle.sty. When that is done the `options' are processed in the order specified, by reading the files opt1.sty[*], opt2.sty, etc. This implies that definitions, made in the file docstyle.sty can be overridden in one of the option files. It is even possible to redefine code from the very kernel of LATEX, but you have to know what you are doing.

Some care has to be taken in writing document-style options, because a number of problems can occur. First of all, if a document-style option should be modest in size; if it tries to redefine most of the code in docstyle.sty I think you should write (and maintain) your own, complete, document style. Next, as it was possible to override definitions from the main file in an option file, it is of course also possible to override definitions made in another option file. When this happens, your document might depend on the order in which you have specified your document-style options.

This mechanism of overriding definitions from the main document style is exploited in the babel system. The macros that contain the hard-wired texts are redefined in the common part of babel, replacing each of these texts with a unique macro. These macros have to be defined in the language-specific files.